﻿using BMS.Entity.RBAC;
using BMS.IRepository;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BMS.Repository
{
    public class UserRepository : BaseRepository<UserInfo>, IUserRepository
    {
        private readonly DbContext db;
        public UserRepository(DbContext db) : base(db)
        {
            this.db = db;
        }
        /// <summary>
        /// 根据登录用户名获取用户信息
        /// </summary>
        /// <param name="loginName">登录名称</param>
        /// <returns></returns>
        public async Task<UserInfo> GetUserbyLoginName(string loginName)
        {
            var users = (await GetAll()).Where(m => m.LoginName == loginName && m.IsDeleted == false).AsNoTracking();
            var user = await users.FirstOrDefaultAsync();
            return user;
        }
    }
}
